package com.selenium.util;

import java.io.IOException;

import org.openqa.selenium.By;

public class GetByLocator {
	
	public static By getLocator(String key) {
		ProUtil prop;
		try {
			prop = new ProUtil("element.properties");
			String locator = prop.getProp(key);
			String locatorType = locator.split(">")[0];
			String locatorValue = locator.split(">")[1];
			
			if(locatorType.equals("id")) {
				return By.id(locatorValue);
			}else if(locatorType.equals("xpath")){
				return By.xpath(locatorValue);
			}else if(locatorType.equals("class")) {
				return By.className(locatorValue);
			}else if(locatorType.equals("name")){
				return By.name(locatorValue);
			}
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return null;
		
		
	}

}
